package com.tianbao54.kotlin_01

class ThePerson(address: String, name: String) {

    val age: Int get() = 20
    var address = address
        get() {
            println("get method invoke")
            return field
        }
        set(value)  {
            println("setter invoke")
            field = value
        }
    var name:String = name
}

fun main(args: Array<String>) {

    var person = ThePerson("beijing", "zhangsan")
    // 调用的是 age get 方法
    println("age = ${person.age}")
    println("address = ${person.address}")
    person.address = "nanchang"
    println("address = ${person.address}")
    println("name = ${person.name}")
    person.name = "lisi"
    println("name = ${person.name}")
}